<% layout('/layouts/default.html', {title: '考核任务信息表管理', libs: ['layout','dataGrid','validate','fileupload','inputmask','ueditor']}){ %>
<style>
	.menu {
		padding: 2px;
		cursor: pointer;
		margin: 2px 1px 2px;
	}

	.options {
		position: absolute;
		display: none;
		width: 100px;
		height: 200px;
		background: #eee;
		/*overflow: auto;*/
	}

	.menu:hover .options {
		display: block;
	}
	.ui-jqgrid .ui-jqgrid-btable {
		margin-bottom: 170px;
	}

	.pp {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.dd {
		/*padding: 4% 15%;*/
		border: 1px solid #0079fe;
		color: #0079fe;
	}

	.options {
		width: 136.34px;
		/*display: block;*/
		height: 170px;
		background-color: white;
		box-shadow: 1px 14px 20px 2px #e8e8e8;
		/*top: 8.3%;*/
		right: 4.7%;
	}

	.options div {
		text-align: center;
		/*padding: 5px 5px;*/

	}

	.options div:hover {
		background-color: rgba(24, 144, 255, 1);

	}

	.options div:hover a {
		color: #eeeeee;

	}

	.menu:hover .options {
		animation: anim .4s;
	}

	@keyframes anim {
		0% {
			height: 0px;
		}
		100% {
			height: 170px;
		}
	}

	#leftDataGrid tr{
		cursor: pointer;
	}
	.SelectBG td{
		background: #eaeaea !important;
		background-color: #eaeaea !important;
		color:blue;
	}
</style>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div style="float: left">
				<button class="btn btn-default btn-sm" id="dingWei" style="font-size: 16px" onclick="js.closeCurrentTabPage()">
					返回
				</button>
			</div>
			<#form:form id="searchForm"  model="${dcSupExamSumQuota}" method="post" class="form-inline " data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<!--此处为导出时选择的列的插入位置-->
			<#form:hidden path="exportColumn" />
			<div style="float: right">
				<div class="form-group">
					<label class="control-label">${text('指标类别')}：</label>
					<div class="control-inline" style="width: 400px;">
						<#form:select path="quotaTypes" dictType="dc_quotaType" multiple="true" class="form-control" blankOptionLabel="全 部" onchange="changeForm()" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('体系版本')}：</label>
					<div class="control-inline" style="width: 280px;">
						<#form:select path="versionNumber" id="version" items="${versions}" itemLabel="versionName" itemValue="version" class="form-control" onchange="changeForm()" data-placeholder="请选择版本"/>
					</div>
				</div>
				<div class="form-group">
					<div class="control-inline">
						<a href="#" id="yinru" class="btn btn-primary text " style="" title="${text('引入最近报送指标')}">&nbsp;引入报送指标</a>
					</div>
				</div>
				<div class="form-group">
					<div class="control-inline">
						<a href="#" id="export" class="btn btn-primary text " style="" title="${text('导出')}"> <i
								class="glyphicon glyphicon-export">&nbsp;导 出</i></a>
					</div>
				</div>
				<div class="form-group">
					<div class="control-inline">
						<a href="#" id="exportDocument" class="btn btn-primary text " style=""
						   title="${text('导入')}"> <i class="glyphicon glyphicon-import">&nbsp;导 入</i></a>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
</div>
	<iframe id="mainFrameBottom" name="mainFrameBottom" frameborder="0" onresize="noresize" style="position: absolute; background: transparent; width: 100%; height:100%;"></iframe>
<% } %>
<script>
	var win = $("#mainFrameBottom")[0].contentWindow;
	let dcSupExamSumQuota =${toJson(dcSupExamSumQuota)};
	// 切换版本 查询左侧数据信息
	$(function (){
		changeMainFrame();
	})

	function baseRefresh(){
		location.reload();
	}

	function changeForm(){
		changeMainFrame();
	}

	function isUndefined(version){
		if (version == undefined){
			return '';
		}
		return version;
	}
	function changeMainFrame(){
		let version=$("#version").val();
		// 用于传递指标类别参数
		let quotaTypes=$("#quotaTypes").val();
		$('#mainFrameBottom').attr('src', '${ctx}/quota/dcSupExamSumQuota/leftOrgs?examId='+dcSupExamSumQuota.examId+'&versionNumber='+isUndefined(version)+"&versionName="+$("#select2-version-container").text()+'&examYear='+dcSupExamSumQuota.remarks2+"&types="+quotaTypes);
	}

	function getDate(){
		let now=new Date()
		let date2= now.toLocaleDateString().split("/");
		let result="";
		for (let key in date2){
			if (key == 1){
				if (date2[key].length < 2){
					date2[key] = "0"+date2[key];
				}
			}
			result=result+date2[key];
		}
		let timeString = now.toLocaleTimeString().replace(":","").replace(":","").substring(0,4);
		return result+timeString;
	}

	$("#export").click(function (){
		js.layer.open({
			type: 1,
			area: ['500px'],
			title: '${text("导出指标汇总数据")}',
			resize: false,
			scrollbar: true,
			content: js.template('exportTpl'),
			success: function(layero, index){
				layero.find('input[type="checkbox"]').iCheck();
			},
			btn: ['<i class="fa fa-check"></i> ${text("导出")}',
				'<i class="fa fa-remove"></i> ${text("关闭")}'],
			btn1: function(index, layero){
				// 获取选中的列
				let exportColumn=[];
				layero.find("input[name='exportColumn']:checkbox").each(function(){
					if(true == $(this).is(':checked')){
						exportColumn.push($(this).val());
					}
				});
				// 将选中的列，放到查询条件中
				$('#exportColumn').val(exportColumn);
				// 获取用户选择的体系版本
				let version=$("#version").val();
				// 提交到后台导出
				js.ajaxSubmitForm($('#searchForm'), {
					url:'${ctx}/quota/dcSupExamSumQuotaInfo/newExport?versionNumber='+isUndefined(version)+'&examId='+dcSupExamSumQuota.examId+"&remarks3="+$("#quotaTypes").val()+"&remarks2="+dcSupExamSumQuota.remarks2,
					downloadFile:true
				});
			}
		});
	})

	$("#exportDocument").click(function () {
		js.layer.open({
			type: 1,
			area: ['400px'],
			title: '${text("导入指标数据")}',
			resize: false,
			scrollbar: true,
			content: js.template('importTpl'),
			success: function (layero, index) {
				layero.find('input[type="checkbox"]').iCheck();
			},
			btn: ['<i class="fa fa-check"></i> ${text("导入")}',
				'<i class="fa fa-remove"></i> ${text("关闭")}'],
			btn1: function (index, layero) {
				let form = {
					inputForm: layero.find('#inputForm'),
					file: layero.find('#file').val()
				};
				if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))) {
					js.showMessage("${text('文件不正确，请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
					return false;
				}
				js.ajaxSubmitForm(form.inputForm, function (data) {
					if (data.result == Global.TRUE) {
						var  message=data.message
						if(message.indexOf("&") !=-1){
							let data_info = message.split("&");
							js.showMessage(data_info[1]);
							baseRefresh();
						}else{
							js.showMessage(message);
						}
						js.layer.closeAll();

					}else{
						js.showMessage(data.message);
					}
				}, "json");
				return true;
			}
		})
	})

	// 引入报送指标
	$("#yinru").click(function () {
		let versionNumber =$("#version").val()
		if(versionNumber==null){
			js.showMessage("引入失败,仅未发布的保存版本可以引入");
			return
		}
		// 版本号需要去除空格
		if(versionNumber.trim()){
			layer.open({
				type: 1
				,title: "" //不显示标题栏
				,btn: ['确认', '取消']
				,btnAlign: 'c'
				,area: '300px;'
				,moveType: 1 //拖拽模式，0或者1
				,content: '<div style="padding: 50px">您确定引入最近报送单位指标到此版本吗</div>'
				,yes: function(layero){
					js.ajaxSubmit('${ctx}/quota/dcSupExamSumQuotaInfo/introQuotaInfo?examId='+dcSupExamSumQuota.examId+'&versionNumber='+$("#version").val(), function(data){
						js.showMessage(data.message);
						if(data.result == Global.TRUE){
							// $("#dataGrid").dataGrid('refresh', 1);
							// 刷新父页面左侧的被考核单位
							baseRefresh();
						}
					})
				}
			});
		}else{
			js.showMessage("引入失败,仅未发布的保存版本可以引入");
		}

	})

</script>
<script id="importTpl" type="text/template">//<!--
<form id="inputForm" action="${ctx}/quota/dcSupExamSumQuotaInfo/newImportData" method="post" enctype="multipart/form-data"
    class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
    <div class="row">
        <div class="col-xs-12 col-xs-offset-1">
            <input type="file" id="file" name="file" class="form-file"/>
            <#form:hidden path="examId" />
            <#form:hidden path="remarks2" />
            <div class="mt10 pt5">
                <a href="${ctx}/quota/dcSupExamSumQuotaInfo/importTemplate" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> ${text('下载模板')}</a>
            </div>
            <font color="red" class="pull-left mt10">
                ${text('提示：仅允许导入“xls”或“xlsx”格式文件！')}
            </font>
        </div>
    </div>
</form>
//--></script>
<script id="exportTpl" type="text/template">
	<form id="inputForm2" action="" method="post" enctype="multipart/form-data"
		  class="form-horizontal mt20 mb10" style="overflow:auto;max-height:250px;">
		<div class="row">
			<div class="col-xs-12 col-xs-offset-1">
				<div style="color: #8B8986;">请选择要导出的列</div>
				<div class="mt10 pt5">
					<span id="exportColumn" class="icheck" class="form-control required">
					<!--此处为可选项-->
					<label><input type="checkbox" id="exportColumn2" name="exportColumn" value="quotaType" class="form-control" checked/> 指标类别</label>
					<label><input type="checkbox" id="exportColumn3" name="exportColumn" value="sortNum" class="form-control" checked/> 序号</label>
					<label><input type="checkbox" id="exportColumn4" name="exportColumn" value="quotaContent" class="form-control" checked/> 目标内容</label>
					<label><input type="checkbox" id="exportColumn5" name="exportColumn" value="quotaUnit" class="form-control" checked/> 单位</label>
					<label><input type="checkbox" id="exportColumn6" name="exportColumn" value="quotaWeight" class="form-control" checked/> 权数</label>
					<label><input type="checkbox" id="exportColumn7" name="exportColumn" value="assessMethod" class="form-control" checked/> 考核方式</label>
					<label><input type="checkbox" id="exportColumn8" name="exportColumn" value="currentYaerGoal" class="form-control" checked/> 本年度目标</label>
					<label><input type="checkbox" id="exportColumn9" name="exportColumn" value="lastYaerGoal" class="form-control" checked/> 上一年度目标任务</label>
					<label><input type="checkbox" id="exportColumn10" name="exportColumn" value="lastYearComplete" class="form-control" checked/> 上一年度完成情况</label>
					<label><input type="checkbox" id="exportColumn11" name="exportColumn" value="remarks" class="form-control" checked/> 备注</label>
						<!--是否过滤类型，默认不过滤-->
					<div style="border-bottom: 1px solid #eee;margin: 8px 2px;"></div>
					<div style="color: #8B8986; padding-bottom: 10px;">默认导出全部类型，可以选择单独导出某一类型</div>
					<label><input type="checkbox" id="exportColumn13" name="exportColumn" value="onlyGuanJian" class="form-control"/> 只导出关键指标</label>
					<label><input type="checkbox" id="exportColumn16" name="exportColumn" value="onlyDanXiang" class="form-control"/> 只导出单项指标</label>
					<input type="hidden" name="!exportColumn" value=""/></span>
				</div>
				<font color="red" class="pull-left mt10">
					${text('提示：导出文件不支持再次导入！')}
				</font>
			</div>
		</div>
	</form>
</script>

